package day8.bank;

/**
 * @author oldliu
 * @since 1.0
 */
public class Depositer extends Thread {
    private final Account ac;

    public  Depositer(String name, Account ac){
        super(name);
        this.ac=ac;
    }

    @Override
    public void run() {
        while (true){
            try {
                sleep(3000);
                ac.deposit(4500);
                System.out.println(super.getName()+"存钱4500元，现在余额是"+ac.getMoney()+"元");
                synchronized (ac){
                    ac.notifyAll();
                }

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
